﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CustomControls.Complex;
using DBO;
using CommonLibrary;
using DBO.Economy;
using ClientBusinessManagement;

namespace WinFormClient
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            troopList1.onEconomicOperation += new EventHandler(troopList1_onEconomicOperation);
        }

        void troopList1_onEconomicOperation(object sender, EventArgs e)
        {
            updatePlayerResources();
        }

        public Player Player
        {
            get { return _player; }
            set
            {
                _player = value;
                updatePlayerResources();
                initTroopList(value.Race);
            }
        }

        private void updatePlayerResources()
        {
            headerResources1.Resources = ClientBusinessManagement.ClientDataHandler.GetPlayerResources(_player);
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void initTroopList(string race)
        {
            if (race.ToLower() == "heirs")
            {
                troopList1.AddTroop("footman");
                troopList1.AddTroop("archer");
                troopList1.AddTroop("knight");
            }
            else
            {
                troopList1.AddTroop("militian");
                troopList1.AddTroop("knife_thrower");
                troopList1.AddTroop("ranger");

            }
        }

        private Player _player;
        private DictionnaryRepository RessourceDictionary = ClientBusinessManagement.ClientDataSingleton.Instance.ResourceRepository;

    }
}
